<?php

/**
 * AimNews form.
 *
 * @package    sf_sandbox
 * @subpackage form
 * @author     Hindua88
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class AimNewsForm extends BaseAimNewsForm
{
  public function configure()
  {
      unset($this['created_at'], $this['updated_at'], $this['is_active']);
    
      $this->setWidget('title', new sfWidgetFormTextArea(array(), array('rows' => 5, 'cols' => 80)));
      $this->setWidget('teaser', new sfWidgetFormTextArea(array(), array('rows' => 5, 'cols' => 80)));
      $this->setWidget('content', new sfWidgetFormCKEditor());
      
      $src = '/uploads/images/'.$this->getObject()->image;
      $this->setWidget('image', new sfWidgetFormInputFileEditableCustom(array(
        'label'    => 'Image',
        'file_src' => $src,
        'is_image' => true,
        'edit_mode' => !$this->isNew(),
        //'template' => '%file% %input% %delete% %delete_label%'
      )));
      
      $path_upload = sfConfig::get('sf_upload_dir').'/images';
      $this->setValidator('image', new sfValidatorFile(array(
        'required'  => false,
        'path'      => $path_upload,
        'mime_types' => 'web_images'
      )));
      $this->setValidator('image_delete', new sfValidatorPass());
      
      $this->setValidator('title', new sfValidatorString());
      $this->setValidator('teaser', new sfValidatorString());
      $this->setValidator('content', new sfValidatorString());
      $this->setValidator('user_id', new sfValidatorDoctrineChoice(
        array('model' => $this->getRelatedModelName('AimUser'),
              'required' => true
      )));
      $this->setWidget('date', new sfWidgetFormDateJQueryUI());
      $this->setValidator('date', new sfValidatori18nDate());
  }
}
